﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Xml.Linq;
using RuleCode.Table;

namespace map.manage
{
    public partial class configshop_inner2 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                bind1();
                bind2();
            }
            //MessageBox.Show(this.Page, Request["divid"].ToString());
        }

        private void bind1()
        {
            cbshopdivelement sde =
                    cbshopdivelement.findorcreate(AliApi.appUserId, Request.Params["divid"].ToString());
            if (sde.elementrecid.ToString()!="")
            {
                cbshoppageelement spe = cbshoppageelement.Find(" recid = " + sde.elementrecid.ToString());
                RadioButtonList1.SelectedValue = spe.cbname.ToString();
            }
        }
        private void bind2()
        {
            LinkButton3.Visible = true;
            string ScriptTag = "";
            if (RadioButtonList1.SelectedValue == "招牌栏目")
            {
                ScriptTag =
                    "<script type=\"text/javascript\">setsrc('../member/configshop_head.aspx?replace=zyj');</script>";
            }
            if (RadioButtonList1.SelectedValue == "网站导航栏")
            {
                ScriptTag =
                    "<script type=\"text/javascript\">setsrc('../member/configshop_sitecata.aspx?replace=zyj');</script>";
            }
            if (RadioButtonList1.SelectedValue == "商品分类")
            {
                LinkButton3.Visible = false;
                ScriptTag =
                    "<script type=\"text/javascript\">setsrc('../member/configshop_shopcata.aspx?replace=zyj');</script>";
            }
            if (RadioButtonList1.SelectedValue == "基本信息")
            {
                LinkButton3.Visible = false;
                ScriptTag =
                    "<script type=\"text/javascript\">setsrc('../member/configshop_intro.aspx?replace=zyj');</script>";
            }
            if (RadioButtonList1.SelectedValue == "当前页面位置")
            {
                LinkButton3.Visible = false;
                ScriptTag =
                    "<script type=\"text/javascript\">setsrc('../member/configshop_curpath.aspx?replace=zyj');</script>";
            }
            if (RadioButtonList1.SelectedValue == "精品推荐")
            {
                LinkButton3.Visible = false;
                ScriptTag =
                    "<script type=\"text/javascript\">setsrc('../member/configshop_itemlist.aspx?replace=zyj&filter=jptj');</script>";
            }
            if (RadioButtonList1.SelectedValue == "最新商品")
            {
                LinkButton3.Visible = false;
                ScriptTag =
                    "<script type=\"text/javascript\">setsrc('../member/configshop_itemlist.aspx?replace=zyj&filter=zxsp');</script>";
            }
            if (RadioButtonList1.SelectedValue == "商品列表")
            {
                LinkButton3.Visible = false;
                ScriptTag =
                    "<script type=\"text/javascript\">setsrc('../member/configshop_itemlist.aspx?replace=zyj');</script>";
            }
            if (RadioButtonList1.SelectedValue == "商品内容")
            {
                LinkButton3.Visible = false;
                ScriptTag =
                    "<script type=\"text/javascript\">setsrc('../member/configshop_iteminfo.aspx?replace=zyj');</script>";
            }
            if (RadioButtonList1.SelectedValue == "论坛文章列表")
            {
                LinkButton3.Visible = false;
                ScriptTag =
                    "<script type=\"text/javascript\">setsrc('../member/configshop_articlelist.aspx?replace=zyj');</script>";
            }
            if (RadioButtonList1.SelectedValue == "论坛文章内容")
            {
                LinkButton3.Visible = false;
                ScriptTag =
                    "<script type=\"text/javascript\">setsrc('../member/configshop_articleinfo.aspx?replace=zyj');</script>";
            }
            if (RadioButtonList1.SelectedValue == "友情链接列表")
            {
                ScriptTag =
                    "<script type=\"text/javascript\">setsrc('../member/pfriendref.aspx');</script>";
            }
            if (RadioButtonList1.SelectedValue == "站内搜索")
            {
                LinkButton3.Visible = false;
                ScriptTag =
                    "<script type=\"text/javascript\">setsrc('../member/configshop_search.aspx?replace=zyj');</script>";
            }
            if (RadioButtonList1.SelectedValue == "商店位置")
            {
                LinkButton3.Visible = false;
                ScriptTag =
                    "<script type=\"text/javascript\">setsrc('../member/configshop_position.aspx?replace=zyj');</script>";
            }
            if (RadioButtonList1.SelectedValue == "搜索结果")
            {
                LinkButton3.Visible = false;
                ScriptTag =
                    "<script type=\"text/javascript\">setsrc('../member/configshop_searchresult.aspx?replace=zyj');</script>";
            }
            if (RadioButtonList1.SelectedValue == "联系信息")
            {
                LinkButton3.Visible = false;
                ScriptTag =
                    "<script type=\"text/javascript\">setsrc('../member/configshop_contactinfo.aspx?replace=zyj');</script>";
            }
            if (RadioButtonList1.SelectedValue == "实体照片")
            {
                LinkButton3.Visible = false;
                ScriptTag =
                    "<script type=\"text/javascript\">setsrc('../member/configshop_entitypic.aspx?replace=zyj');</script>";
            }
            if (RadioButtonList1.SelectedValue == "关于我们")
            {
                LinkButton3.Visible = false;
                ScriptTag =
                    "<script type=\"text/javascript\">setsrc('../member/configshop_aboutus.aspx?replace=zyj');</script>";
            }
            if (RadioButtonList1.SelectedValue == "公告")
            {
                ScriptTag =
                    "<script type=\"text/javascript\">setsrc('../member/configshop_gonggao.aspx?replace=zyj');</script>";
            }
            if (ScriptTag == "")
            {
                ScriptTag =
                    "<script type=\"text/javascript\">setsrc('../member/configshop_custom.aspx?replace=zyj&ScriptTag="
                     + System.Web.HttpUtility.UrlEncode(RadioButtonList1.SelectedIndex.ToString()) 
                     + "');</script>";
            }
            

            if (ScriptTag != "")
            {
                ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(),
                            "messagew1", ScriptTag, false);
            }
        }


        protected void RadioButtonList1_SelectedIndexChanged(object sender, EventArgs e)
        {
            bind2();
            if (
                RadioButtonList1.SelectedValue == "论坛文章列表" ||
                RadioButtonList1.SelectedValue == "论坛文章内容" ||
RadioButtonList1.SelectedValue == "商品列表" ||
RadioButtonList1.SelectedValue == "商品内容")
            {
                Label_id.Visible = true;
                TextBox_id.Visible = true;
            }
            else
            {
                Label_id.Visible = false;
                TextBox_id.Visible = false;
            }
        }
        /// <summary>
        /// 编辑按钮,打开新页面
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void Button1_Click1(object sender, EventArgs e)
        {
            string ScriptTag =
                        "";
            if (RadioButtonList1.SelectedValue == "招牌栏目")
            {
                ScriptTag =
                    "<script type=\"text/javascript\">newpage('../member/designshop_head.aspx');</script>";
            }
            if (RadioButtonList1.SelectedValue == "网站导航栏")
            {
                ScriptTag =
                    "<script type=\"text/javascript\">newpage('../member/designshop_sitecata.aspx');</script>";
            }
            if (RadioButtonList1.SelectedValue == "商品分类")
            {
                ScriptTag =
                    "<script type=\"text/javascript\">newpage('../member/designshop_shopcata.aspx');</script>";
            }
            if (RadioButtonList1.SelectedValue == "基本信息")
            {
                ScriptTag =
                    "<script type=\"text/javascript\">newpage('../member/designshop_intro.aspx');</script>";
            }

            if (RadioButtonList1.SelectedValue == "当前页面位置")
            {
                ScriptTag =
                    "<script type=\"text/javascript\">newpage('../member/designshop_curpath.aspx');</script>";
            }
            if (RadioButtonList1.SelectedValue == "商品列表")
            {
                ScriptTag =
                    "<script type=\"text/javascript\">newpage('../member/designshop_itemlist.aspx');</script>";
            }
            if (RadioButtonList1.SelectedValue == "商品内容")
            {
                ScriptTag =
                    "<script type=\"text/javascript\">newpage('../member/designshop_iteminfo.aspx');</script>";
            }
            if (RadioButtonList1.SelectedValue == "论坛文章列表")
            {
                ScriptTag =
                    "<script type=\"text/javascript\">newpage('../member/designshop_articlelist.aspx');</script>";
            }
            if (RadioButtonList1.SelectedValue == "论坛文章内容")
            {
                ScriptTag =
                    "<script type=\"text/javascript\">newpage('../member/designshop_articleinfo.aspx');</script>";
            }
            if (RadioButtonList1.SelectedValue == "友情链接列表")
            {
                ScriptTag =
                    "<script type=\"text/javascript\">newpage('../member/designshop_linklist.aspx');</script>";
            }
            if (RadioButtonList1.SelectedValue == "公告")
            {
                ScriptTag =
                    "<script type=\"text/javascript\">newpage('../member/designshop_gonggao.aspx');</script>";
            }
            if (RadioButtonList1.SelectedValue == "站内搜索")
            {
                ScriptTag =
                    "<script type=\"text/javascript\">newpage('../member/designshop_search.aspx');</script>";
            }
            if (RadioButtonList1.SelectedValue == "实体照片")
            {
                ScriptTag =
                    "<script type=\"text/javascript\">newpage('../member/designshop_entitypic.aspx');</script>";
            }
            if (RadioButtonList1.SelectedValue == "联系信息")
            {
                ScriptTag =
                    "<script type=\"text/javascript\">newpage('../member/designshop_contactinfo.aspx');</script>";
            }
            if (RadioButtonList1.SelectedValue == "关于我们")
            {
                ScriptTag =
                    "<script type=\"text/javascript\">newpage('../member/designshop_aboutus.aspx');</script>";
            }
            if (RadioButtonList1.SelectedValue == "商店位置")
            {
                ScriptTag =
                    "<script type=\"text/javascript\">newpage('../member/designshop_position.aspx');</script>";
            }
            if (RadioButtonList1.SelectedValue == "搜索结果")
            {
                ScriptTag =
                    "<script type=\"text/javascript\">newpage('../member/designshop_searchresult.aspx');</script>";
            }
            if (ScriptTag == "")
            {
                ScriptTag =
                    "<script type=\"text/javascript\">newpage('../member/designshop_custom.aspx?ScriptTag="
                    + System.Web.HttpUtility.UrlEncode(RadioButtonList1.SelectedIndex.ToString()) 
                    + "');</script>";
            }


            ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(),
                    "messagew123", ScriptTag, false);
        }
        /// <summary>
        /// 刷新按钮
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void Button2_Click(object sender, EventArgs e)
        {
            bind2();
        }
        /// <summary>
        /// 确定保存
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void Button3_Click(object sender, EventArgs e)
        {
            if (Request.Params["divid"] != null)
            {
                cbshopdivelement sde = 
                    cbshopdivelement.findorcreate(AliApi.appUserId, Request.Params["divid"].ToString());
                cbshoppageelement spe = cbshoppageelement.findorcreate(AliApi.appUserId,
                    RadioButtonList1.SelectedValue);
                sde.elementrecid.Value = spe.RECID.ToString();
                sde.Modify();
            }

            string ScriptTag =
            "<script type=\"text/javascript\">comfirmdiv(document.getElementById('ctl00_ContentPlaceHolder1_RadioButtonList1'),'"+
            this.TextBox_id.Text.Trim()+"');</script>";
            ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(),
                    "messagew111", ScriptTag, false);


        }




    }
}
